package com.stx.hotkey.client.core.worker;

import com.google.common.eventbus.Subscribe;

import java.util.ArrayList;
import java.util.List;

/**
 *  eventbus监听worker信息变动
 */
public class WorkerChangeSubscriber {

    /**
     * 监听worker信息变动
     */
    @Subscribe
    public void connectAll(WorkerInfoChangeEvent event) {
        List<String> addresses = event.getAddresses();

        if (addresses == null){
            addresses = new ArrayList<>();
        }

        WorkerInfoHolder.mergeAndConnectNew(addresses);
    }
}
